package com.guqj.pattern.builder.hero;

import java.util.List;

import com.guqj.pattern.builder.builder.TraxexBuilder;
import com.guqj.pattern.builder.modal.Equipment;
import com.guqj.pattern.builder.modal.Level;
import com.guqj.pattern.builder.modal.Skill;

public class Traxex implements Hero {

	private String userName; // 玩家id
	private Level level; // 玩家等级
	private List<Skill> skills; // 学习技能点
	private List<Equipment> equipments; // 当前装备

	public Traxex(TraxexBuilder traxexBuilder){
		setUserName(traxexBuilder.userName);
		setLevel(traxexBuilder.level);
		setSkill(traxexBuilder.skills);
		setEquipment(traxexBuilder.equipments);
	}
	
	@Override
	public void setUserName(String name) {
		this.userName = name;
	}

	@Override
	public void setLevel(Level level) {
		this.level = level;
	}

	@Override
	public void setSkill(List<Skill> skills) {
		this.skills = skills;
	}

	@Override
	public void setEquipment(List<Equipment> equipments) {
		this.equipments = equipments;
	}

	private String getUserName() {
		return userName;
	}

	private Level getLevel() {
		return level;
	}

	private List<Skill> getSkills() {
		return skills;
	}

	private List<Equipment> getEquipments() {
		return equipments;
	}

	@Override
	public String toString() {
		String level = getLevel().getDesc();

		String skillDesc = "[";
		boolean firstFlag = true;
		for (Skill skill : getSkills()) {
			if (firstFlag) {
				firstFlag = false;
			} else {
				skillDesc += ", ";
			}

			skillDesc += skill.getDesc();
		}
		skillDesc += "]";

		String equipmentDesc = "[";
		firstFlag = true;
		for (Equipment equipment : getEquipments()) {
			if (firstFlag) {
				firstFlag = false;
			} else {
				equipmentDesc += ", ";
			}

			equipmentDesc += equipment.getDesc();
		}
		equipmentDesc += "]";

		return "玩家：" + getUserName() + "\n等级：" + level + "\n学习技能：" + skillDesc + "\n当前装备：" + equipmentDesc;
	}
}
